package com.hujf.netty.inandoutboundhandler;

import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.CharsetUtil;
import io.netty.util.concurrent.EventExecutorGroup;

/**
 * @author Hujf
 * @title: MyClientHandler
 * @date 2021/2/6 0006上午 9:47
 * @description: TODO
 */
public class MyClientHandler extends SimpleChannelInboundHandler<Long> {
    //读取
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Long msg) throws Exception {
        System.out.println("客户端读取服务端数据"+ msg);
    }

    //发送

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {

        //专有格式发送
     //   ctx.writeAndFlush(Unpooled.copiedBuffer("11111111", CharsetUtil.UTF_8));
        System.out.println("给服务器发数据----123456L");
        ctx.writeAndFlush(123456L);
    }
}
